<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>销售商品统计</title>
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:358px;">
			<div data-options="region:'center'">
				<div id="p" class="easyui-panel" style="width:100%;height:100%;padding:0px;">
					<div>
						<table id="dg" style="width: 100%;" class="table_style">
						</table>
					</div>
					<div id="toolbar"></div>
				</div>
			</div>
			<div id="addFrame" class="easyui-dialog" style="width:400px;height:350px;padding: 20px 30px;margin-left:;" data-options="title:'查询',buttons:'#bb',closed:true">
				<form id="fm" style="margin: 0px 0px ;" method="post">
				</form>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src="../../../JS/buildDialogSearch.js"></script>
	<script type="text/javascript">
		var searchType = SEARCH_INTERNAL_NAME + SEARCH_CUSTOMER_TYPE + SEARCH_CUSTOMER_NAME + SEARCH_DISTRIBUTION_DATE;

		var content = buildSearchOptions(searchType, "");
		$("#fm").append(content);
		//配送单位
		$('#search_customer_type').combobox({
			valueField: 'CUSTOMER_TYPE',
			textField: 'CUSTOMER_TYPE',
			panelHeight: 200,
			mode: 'remote',
			method: 'get',
			editable:false,
			url: RemoteLinkAddress + "/logistics/customertype/listall.do",
			onSelect:function(record)
			{
				var _url="";
				_url=RemoteLinkAddress + '/logistics/customer/listall.do?CUSTOMER_TYPE='+record.CUSTOMER_TYPE;
				$('#search_customer_type').combobox("reload",_url);
			}
		});
		//商品名称
		$('#search_commodity_name').combobox({
			valueField: 'INTERNAL_NAME',
			textField: 'INTERNAL_NAME',
			panelHeight: 200,
			mode: 'remote',
			method: 'get',
			editable:false,
			url: RemoteLinkAddress + "/logistics/customertype/listall.do",
			onSelect:function(record)
			{
				var _url="";
				_url=RemoteLinkAddress + '/logistics/customer/listall.do?INTERNAL_NAME='+record.INTERNAL_NAME;
				$('#search_commodity_name').combobox("reload",_url);
			}
		});
		//用户组
		$('#search_customr_name').combobox({
			valueField: 'CUSTOMER_NAME',
			textField: 'CUSTOMER_NAME',
			panelHeight: 200,
			mode: 'remote',
			method: 'get',
			url: RemoteLinkAddress + '/logistics/customer/listall.do',
			onChange: function(newValue, oldValue) {
				if(newValue != "" && newValue != undefined) {
					var url = RemoteLinkAddress + "/logistics/customer/findbypinyin?PINYINFIELDNAME=" + newValue.trim();
					$(this).combobox("reload", url);
				}
			}
		});

		function doSearch() {
			var searchCondition = processSearchCondition();
			var _url = RemoteLinkAddress + '/logistics/ salesorder/findbydetail.do ' + searchCondition;
			$('#dg').datagrid('options').url = _url;
			$('#dg').datagrid('reload');
			$('#addFrame').dialog('close');
		}

		function closeForm() {
			$('#addFrame').dialog('close');
		}

		function searchmore() {

			$("#addFrame").dialog('open').dialog('center');
			$('#fm').form('clear');
		}

		function exportExcel() {
			var searchCondition = processSearchCondition();
			$.messager.confirm("提示", "确认导出Excel表格吗？", function(r) {
				if(r) {
					$.ajax({ //调用ajax方法，从服务器获取到该订单的所有数据
						type: "get",
						dataType: "json", //服务器返回的数据类型
						url: RemoteLinkAddress + "/logistics/statistics/salesbycustomer/excel.do?" + searchCondition,
						success: function(result) {
							window.location.href = result.path;
						}, //请求成功后，接受服务器传来的Json字符串，并做相应的处理
						error: function(xhr, status, error) {
							$.messager.alert("错误", "请求失败!");
						}
					});
				}
			});
		}

		content = AddReceiptsToolBar(1024 + 128, ""); /**根据用户的权限，来决定生成ToolBar的哪些功能**/
		$("#toolbar").append(content); /*在ID=toolbar的标记后面添加content中的内容*/
		$('#dg').datagrid({
			url: RemoteLinkAddress + '/logistics/salesorder/list.do',
			toolbar: '#toolbar',
			method: 'get',
			checkbox: true,
			rownumbers: 'true',
			autoRowHeight: 'true',
			fitColumns: 'false',
			singleSelect: 'true',
			height: 338,
			pagination: true,
			/*表格中的列名以及各自列名的ID*/
			columns: [
				[{
					field: 'cb',
					checkbox: 'true',
				}, {
					field: 'ID',
					title: 'ID',
					width: '2%',
					align: 'center'
				}, {
					field: 'ORDER_NO',
					title: '销售单号',
					width: '13%',
					align: 'center'
				}, {
					field: 'CUSTOMER_TYPE',
					title: '用户组',
					width: '13%',
					align: 'center'
				}, {
					field: 'CUSTOMER_NAME',
					title: '配送单位',
					width: '13%',
					align: 'center'
				}, {
					field: 'DISTRIBUTION_DATE',
					title: '配送时间',
					width: '13%',
					align: 'center'
				}, {
					field: 'LUMP_SUM',
					title: '总价',
					width: '13%',
					align: 'center',
					formatter: function(value, row, index) {
						if(value) {
							return "￥" + value + "元";
						}
					}
				}, {
					field: 'STATE',
					title: '订单状态',
					width: "13%",
					align: 'center'
				},]
			],
			onDblClickRow: function(index, row) {
				var pLocation = "";
				pLocation = "UI/LOGISTICS/SellOrder/SellOrderAdd.html?id=" + row.ID;
				AddTabIn("销售订单详情",parent.$("#tabs"), pLocation);
			}
		});
	</script>

</html>